load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "core",
    srcs = [
        "access_object.go",
        "collect_column_stats_usage.go",
        "common_plans.go",
        "core_init.go",
        "debugtrace.go",
        "encode.go",
        "exhaust_physical_plans.go",
        "explain.go",
        "expression_codec_fn.go",
        "expression_rewriter.go",
        "find_best_task.go",
        "flat_plan.go",
        "foreign_key.go",
        "fragment.go",
        "hashcode.go",
        "hint_utils.go",
        "index_join_path.go",
        "indexmerge_path.go",
        "indexmerge_unfinished_path.go",
        "initialize.go",
        "logical_datasource.go",
        "logical_index_scan.go",
        "logical_initialize.go",
        "logical_plan_builder.go",
        "logical_plans.go",
        "logical_table_scan.go",
        "logical_tikv_single_gather.go",
        "memtable_infoschema_extractor.go",
        "memtable_predicate_extractor.go",
        "mock.go",
        "optimizer.go",
        "partition_prune.go",
        "pb_to_plan.go",
        "physical_plans.go",
        "plan.go",
        "plan_cache.go",
        "plan_cache_instance.go",
        "plan_cache_lru.go",
        "plan_cache_param.go",
        "plan_cache_rebuild.go",
        "plan_cache_utils.go",
        "plan_cacheable_checker.go",
        "plan_clone_generated.go",
        "plan_clone_generator.go",
        "plan_cost_detail.go",
        "plan_cost_ver1.go",
        "plan_cost_ver2.go",
        "plan_to_pb.go",
        "planbuilder.go",
        "point_get_plan.go",
        "preprocess.go",
        "property_cols_prune.go",
        "recheck_cte.go",
        "resolve_indices.go",
        "rule_aggregation_elimination.go",
        "rule_aggregation_push_down.go",
        "rule_aggregation_skew_rewrite.go",
        "rule_collect_plan_stats.go",
        "rule_column_pruning.go",
        "rule_decorrelate.go",
        "rule_derive_topn_from_window.go",
        "rule_eliminate_projection.go",
        "rule_generate_column_substitute.go",
        "rule_inject_extra_projection.go",
        "rule_join_elimination.go",
        "rule_join_reorder.go",
        "rule_join_reorder_dp.go",
        "rule_join_reorder_greedy.go",
        "rule_max_min_eliminate.go",
        "rule_outer_to_inner_join.go",
        "rule_partition_processor.go",
        "rule_predicate_push_down.go",
        "rule_predicate_simplification.go",
        "rule_push_down_sequence.go",
        "rule_resolve_grouping_expand.go",
        "rule_result_reorder.go",
        "rule_semi_join_rewrite.go",
        "rule_topn_push_down.go",
        "runtime_filter.go",
        "runtime_filter_generator.go",
        "scalar_subq_expression.go",
        "show_predicate_extractor.go",
        "stats.go",
        "stringer.go",
        "task.go",
        "task_base.go",
        "tiflash_selection_late_materialization.go",
        "trace.go",
        "util.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/planner/core",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/storage",
        "//pkg/bindinfo",
        "//pkg/bindinfo/norm",
        "//pkg/config",
        "//pkg/distsql",
        "//pkg/domain",
        "//pkg/errctx",
        "//pkg/expression",
        "//pkg/expression/aggregation",
        "//pkg/expression/context",
        "//pkg/expression/contextopt",
        "//pkg/infoschema",
        "//pkg/infoschema/context",
        "//pkg/kv",
        "//pkg/lock",
        "//pkg/lock/context",
        "//pkg/meta/autoid",
        "//pkg/meta/model",
        "//pkg/metrics",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/auth",
        "//pkg/parser/charset",
        "//pkg/parser/format",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/parser/opcode",
        "//pkg/parser/terror",
        "//pkg/parser/types",
        "//pkg/planner/cardinality",
        "//pkg/planner/cascades/base",
        "//pkg/planner/context",
        "//pkg/planner/core/base",
        "//pkg/planner/core/constraint",
        "//pkg/planner/core/cost",
        "//pkg/planner/core/metrics",
        "//pkg/planner/core/operator/baseimpl",
        "//pkg/planner/core/operator/logicalop",
        "//pkg/planner/core/operator/physicalop",
        "//pkg/planner/core/resolve",
        "//pkg/planner/core/rule",
        "//pkg/planner/core/rule/util",
        "//pkg/planner/funcdep",
        "//pkg/planner/property",
        "//pkg/planner/util",
        "//pkg/planner/util/coreusage",
        "//pkg/planner/util/costusage",
        "//pkg/planner/util/debugtrace",
        "//pkg/planner/util/fixcontrol",
        "//pkg/planner/util/optimizetrace",
        "//pkg/planner/util/optimizetrace/logicaltrace",
        "//pkg/planner/util/tablesampler",
        "//pkg/planner/util/utilfuncp",
        "//pkg/privilege",
        "//pkg/sessionctx",
        "//pkg/sessionctx/stmtctx",
        "//pkg/sessionctx/variable",
        "//pkg/sessiontxn",
        "//pkg/sessiontxn/staleread",
        "//pkg/statistics",
        "//pkg/statistics/asyncload",
        "//pkg/statistics/handle/util",
        "//pkg/table",
        "//pkg/table/tables",
        "//pkg/table/temptable",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/types/parser_driver",
        "//pkg/util",
        "//pkg/util/chunk",
        "//pkg/util/codec",
        "//pkg/util/collate",
        "//pkg/util/context",
        "//pkg/util/dbterror",
        "//pkg/util/dbterror/exeerrors",
        "//pkg/util/dbterror/plannererrors",
        "//pkg/util/disjointset",
        "//pkg/util/domainutil",
        "//pkg/util/execdetails",
        "//pkg/util/filter",
        "//pkg/util/hack",
        "//pkg/util/hint",
        "//pkg/util/intest",
        "//pkg/util/intset",
        "//pkg/util/kvcache",
        "//pkg/util/logutil",
        "//pkg/util/mathutil",
        "//pkg/util/memory",
        "//pkg/util/mock",
        "//pkg/util/paging",
        "//pkg/util/parser",
        "//pkg/util/plancodec",
        "//pkg/util/ranger",
        "//pkg/util/ranger/context",
        "//pkg/util/redact",
        "//pkg/util/rowcodec",
        "//pkg/util/sem",
        "//pkg/util/set",
        "//pkg/util/size",
        "//pkg/util/sqlexec",
        "//pkg/util/stmtsummary",
        "//pkg/util/stringutil",
        "//pkg/util/syncutil",
        "//pkg/util/texttree",
        "//pkg/util/tiflashcompute",
        "//pkg/util/tracing",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/coprocessor",
        "@com_github_pingcap_kvproto//pkg/diagnosticspb",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_tikv_client_go_v2//kv",
        "@com_github_tikv_client_go_v2//oracle",
        "@org_golang_x_exp//maps",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "core_test",
    timeout = "short",
    srcs = [
        "binary_plan_test.go",
        "cbo_test.go",
        "collect_column_stats_usage_test.go",
        "common_plans_test.go",
        "enforce_mpp_test.go",
        "exhaust_physical_plans_test.go",
        "expression_test.go",
        "find_best_task_test.go",
        "fragment_test.go",
        "indexmerge_intersection_test.go",
        "indexmerge_path_test.go",
        "indexmerge_test.go",
        "integration_partition_test.go",
        "integration_test.go",
        "logical_plan_trace_test.go",
        "logical_plans_test.go",
        "main_test.go",
        "memtable_infoschema_extractor_test.go",
        "optimizer_test.go",
        "partition_pruning_test.go",
        "physical_plan_test.go",
        "physical_plan_trace_test.go",
        "plan_cache_instance_test.go",
        "plan_cache_lru_test.go",
        "plan_cache_param_test.go",
        "plan_cache_rebuild_test.go",
        "plan_cache_test.go",
        "plan_cacheable_checker_test.go",
        "plan_clone_test.go",
        "plan_cost_detail_test.go",
        "plan_cost_ver1_test.go",
        "plan_cost_ver2_test.go",
        "plan_replayer_capture_test.go",
        "plan_test.go",
        "plan_to_pb_test.go",
        "planbuilder_test.go",
        "point_get_plan_test.go",
        "preprocess_test.go",
        "rule_generate_column_substitute_test.go",
        "rule_join_reorder_dp_test.go",
        "runtime_filter_generator_test.go",
        "stringer_test.go",
        "util_test.go",
    ],
    data = glob([
        "testdata/**",
        "*.go",
    ]),
    embed = [":core"],
    flaky = True,
    shard_count = 50,
    deps = [
        "//pkg/config",
        "//pkg/domain",
        "//pkg/expression",
        "//pkg/expression/aggregation",
        "//pkg/expression/context",
        "//pkg/expression/contextopt",
        "//pkg/expression/contextstatic",
        "//pkg/infoschema",
        "//pkg/kv",
        "//pkg/meta/model",
        "//pkg/metrics",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/auth",
        "//pkg/parser/charset",
        "//pkg/parser/format",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/parser/terror",
        "//pkg/planner",
        "//pkg/planner/core/base",
        "//pkg/planner/core/operator/logicalop",
        "//pkg/planner/core/operator/physicalop",
        "//pkg/planner/core/resolve",
        "//pkg/planner/core/rule",
        "//pkg/planner/property",
        "//pkg/planner/util",
        "//pkg/planner/util/coretestsdk",
        "//pkg/planner/util/costusage",
        "//pkg/planner/util/optimizetrace",
        "//pkg/session",
        "//pkg/sessionctx",
        "//pkg/sessionctx/variable",
        "//pkg/sessiontxn",
        "//pkg/statistics",
        "//pkg/table",
        "//pkg/testkit",
        "//pkg/testkit/ddlhelper",
        "//pkg/testkit/external",
        "//pkg/testkit/testdata",
        "//pkg/testkit/testmain",
        "//pkg/testkit/testsetup",
        "//pkg/testkit/testutil",
        "//pkg/types",
        "//pkg/types/parser_driver",
        "//pkg/util",
        "//pkg/util/benchdaily",
        "//pkg/util/chunk",
        "//pkg/util/collate",
        "//pkg/util/context",
        "//pkg/util/dbterror",
        "//pkg/util/dbterror/plannererrors",
        "//pkg/util/hint",
        "//pkg/util/logutil",
        "//pkg/util/mock",
        "//pkg/util/plancodec",
        "//pkg/util/ranger",
        "//pkg/util/stmtsummary",
        "//pkg/util/tracing",
        "@com_github_golang_snappy//:snappy",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_prometheus_client_model//go",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
